package com.dongdongmovie.service.impl;

import com.dongdongmovie.mapper.TabSellerMapper;
import com.dongdongmovie.pojo.TabSeller;
import com.dongdongmovie.pojo.TabSellerExample;
import com.dongdongmovie.service.TabSeller_Service;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

@Service
@DubboService
public class TabSeller_ServiceImpl implements TabSeller_Service {

    //注入mapper
    @Autowired
    private TabSellerMapper tabSellerMapper;

    //查询数据
    @Override
    public List<TabSeller> show() {
        return tabSellerMapper.selectByExample(null);
    }

    //添加数据
    @Override
    public int add(TabSeller t) {
        return tabSellerMapper.insertSelective(t);
    }

    //根据ID修改数据
    @Override
    public int updatebyId(TabSeller t) {
        return tabSellerMapper.updateByPrimaryKeySelective(t);
    }

    //根据ID删除数据
    @Override
    public int deletebyId(Integer sid) {
        return tabSellerMapper.deleteByPrimaryKey(sid);
    }

    //删除已选数据
    @Override
    public int deleteall(Integer[] sids) {
        List<Integer> list = Arrays.asList(sids);
        TabSellerExample te = new TabSellerExample();
        TabSellerExample.Criteria criteria = te.createCriteria();
        criteria.andSidIn(list);
        return tabSellerMapper.deleteByExample(te);
    }

    //根据id进行查询
    @Override
    public TabSeller showbyId(Integer sid) {
        return tabSellerMapper.selectByPrimaryKey(sid);
    }
}
